package com.hoshiicloud.suppplier.feign.hystrix;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hoshiicloud.common.query.OmnipotentParam;
import com.hoshiicloud.common.query.OmnipotentWrapper;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.goods.entity.goods.Gallery;
import com.hoshiicloud.goods.entity.sku.BaseSku;
import com.hoshiicloud.goods.entity.sku.BaseSkuGallery;
import com.hoshiicloud.goods.entity.sku.VendorGoodsSku;
import com.hoshiicloud.goods.entity.spu.BaseGoodsGallery;
import com.hoshiicloud.goods.entity.spu.BaseSpu;
import com.hoshiicloud.goods.param.sku.*;
import com.hoshiicloud.goods.param.spu.BaseSpuAddParam;
import com.hoshiicloud.goods.param.spu.BaseSpuQueryParam;
import com.hoshiicloud.goods.vo.GoodsPropertiesVo;
import com.hoshiicloud.goods.vo.sku.BaseSkuVo;
import com.hoshiicloud.suppplier.feign.GoodsFeignService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;

/**
 *  商品发布熔断
 * @author Admin
 */
@Slf4j
public class GoodsFeignServiceFallback implements FallbackFactory<GoodsFeignService> {

    @Override
    @HystrixCommand
    public GoodsFeignService create(Throwable throwable) {
        log.error("supplier聚合调用goods失败"+throwable.toString());
        return new GoodsFeignService() {
            @Override
            public Response<BaseSpu> saveBaseSpu(BaseSpuAddParam param) {
                return Response.failed("保存baseSpu并返回的  BaseSpu 对象失败"+ throwable.getMessage());
            }

            @Override
            public Response<BaseSpu> getBaseSpuById(Long id) {
                return Response.failed("通过Id 查询baseSpu信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<Page<BaseSpu>> pageBaseSpuForSupplier(BaseSpuQueryParam param) {
                return Response.failed("分页查询供应商发布的商品列表失败"+ throwable.getMessage());
            }

            @Override
            public Response<Boolean> saveBaseGoodsGalleryBatch(List<BaseGoodsGallery> baseGoodsGalleries) {
                return Response.failed("批量保存BaseSpu与相册关联信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<List<BaseGoodsGallery>> listBaseGoodsGalleryBySpuId(Long baseSpuId) {
                return Response.failed("通过baseSpuId 查询相册关联信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<Long> getMaxWeight(Long storeId) {
                return Response.failed("获取某个店铺下商品权重的最大值失败"+ throwable.getMessage());
            }

            @Override
            public Response<Boolean> saveGalleryBath(List<Gallery> galleries) {
                return Response.failed("批量保存相册信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<List<Gallery>> queryGalleryBatch(List<OmnipotentWrapper> param) {
                return Response.failed("自定义批量查询相册信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<BaseSku> saveBaseSku(BaseSkuAddParam param) {
                return Response.failed("保存BaseSku信息, 并返回保存的 BaseSku对象失败"+ throwable.getMessage());
            }

            @Override
            public Response<List<BaseSkuVo>> listBaseSkuByParam(SkuBaseListParam param) {
                return Response.failed("baseSku信息查询失败"+ throwable.getMessage());
            }

            @Override
            public Response<Boolean> saveBaseSkuGallery(BaseSkuGalleryAddParam param) {
                return Response.failed("保存BaseSku的图片信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<List<BaseSkuGallery>> listBaseSkuGalleryByBaseSkuId(Long baseSkuId) {
                return Response.failed("通过 baseSkuId 获取skuGallery集合失败"+ throwable.getMessage());
            }

            @Override
            public Response<Boolean> saveVendorGoodsSku(VendorGoodsSkuAddParam param) {
                return Response.failed("保存供应商商品SKU信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<VendorGoodsSku> getVendorGoodsSkuById(Long id) {
                return Response.failed("根据Id查询供应商商品sku信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<Boolean> updateVendorGoodsSku(VendorGoodsSkuUpdateParam param) {
                return Response.failed("更新供应商商品SKU信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<Boolean> deleteVendorGoodsSkuById(Long id) {
                return Response.failed("通过Id删除 供应商品商品sku 信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<Boolean> updateVendorGoodsSkuBatch(OmnipotentParam<VendorGoodsSku> params) {
                return Response.failed("通过自定义条件批量更新供应商商品SKU信息(此更新是更新成相同的值)失败"+ throwable.getMessage());
            }

            @Override
            public Response<List<VendorGoodsSku>> listVendorGoodsSku(List<OmnipotentWrapper> param) {
                return Response.failed("自定义条件查询 供应商商品Sku信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<List<GoodsPropertiesVo>> getProperByCateId(Long categoryId, Long companyId) {
                return Response.failed("通过类目Id和租户Id获取属性信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<List<String>> dropdownBox(Long companyId, String propertyName) {
                return Response.failed("通过“名称”获取销售单位和包装单位失败"+ throwable.getMessage());
            }

            @Override
            public Response<List<Map<String, Object>>> getGoodsBrandsByCateId(Long cateId) {
                return Response.failed("根据类目id， 查询某个类目下的品牌信息失败"+ throwable.getMessage());
            }

            @Override
            public Response<String> getCategoryContext(String categoryContextQueryStr) {
                return Response.failed("根据三个类目id组成的字符串（需是父子关系），查询类目名称失败"+ throwable.getMessage());
            }
        };
    }

}
